/**
 * 处理mysql初始化数据
 */
const mysql = require('mysql')
/**
 * 配置连接词数据
 */
const pool = mysql.createPool({
  host: 'localhost',
  port: 3306,
  database: 'demo',
  user: 'root',
  password: '123456',
})

/**
 * @param {String} sql 查询语句
 * @param {function} callBack 回调函数
 */
function query(sql, callBack) {
  pool.getConnection(function (err, connection) {
    connection.query(sql, function (err, rows) {
      callBack(err, rows)
      connection.release();//中断连接
    })
  })
}
module.exports ={
  query
} 